const {
  news
} = require('../data.json')
const path = require('path')
const bURl = 'https://blog.csdn.net/lianzhang861/article/details/80581042'
exports.reply = async (ctx, next) => {
  let mp = require('./index')
  let client = mp.getWechat()
  const message = ctx.weixin
  let reply = ''
  if (message.MsgType === 'text') {
    const content = message.Content
    if (content === '001') {
      reply = '亲爱的，欢迎关注时光的余热\n' + '也可以点击 <a href="' + bURl + '">语音查电影</a>\n'
    } else if (content === '002') {
      reply = '输入2'
    } else if (content === '003') {
      reply = '输入3'
    } else if (content === '004') {
      reply = news
    } else if (content === '005') {
      // 临时图片
      const {
        media_id
      } = await client.handle('uploadMaterial', 'image', path.join(__dirname, '/public/2.jpg'))
      reply = {
        type: 'image',
        media_id
      }
    } else if (content === '006') {
      // 临时视频
      const {
        media_id
      } = await client.handle('uploadMaterial', 'video', path.join(__dirname, 'public/6.mp4'))
      reply = {
        type: 'video',
        media_id,
        title: 'title000',
        description: '回复视频'
      }
    } else if (content === '007') {
      // 临时回复type:music与voice不一样 音乐消息 音乐为线上音乐 需要图片id
      const {
        media_id
      } = await client.handle('uploadMaterial', 'image', path.join(__dirname, 'public/2.jpg'))
      reply = {
        type: 'music',
        title: '音乐', // 不是必须传
        description: '描述', // 不是必须传
        musicUrl: 'http://m.oscaches.com/mp4/djmusic/zw/20190712/1.mp4', // 音乐链接
        HQMusicUrl: 'http://m.oscaches.com/mp4/djmusic/zw/20190712/1.mp4', // 高质量音乐 不是必须传
        ThumbMediaId: media_id // 缩略图的媒体id 必须传
      }
    } else if (content === '008') {
      // 永久图片
      const {
        media_id
      } = await client.handle('uploadMaterial', 'image', path.join(__dirname, 'public/2.jpg'), {
        type: 'image'
      })
      reply = {
        type: 'image',
        media_id
      }
    } else if (content === '009') {
      // 永久视频
      const data = await client.handle('uploadMaterial', 'video', path.join(__dirname, 'public/6.mp4'), {
        type: 'video',
        description: JSON.stringify({
          title: '你看不起我，我更看不起你',
          introduction: '看不起你'
        })
      })
      reply = {
        type: 'video',
        media_id: data.media_id,
        title: '永久视频',
        description: '永久视频'
      }
    } else if (content === '010') {
      // 新增临时素材 语音
      const {
        media_id
      } = await client.handle('uploadMaterial', 'voice', path.join(__dirname, 'public/101.mp3'))
      reply = {
        type: 'voice',
        media_id
      }
    } else if (content === '011') {
      //永久音频
      const data = await client.handle('uploadMaterial', 'voice', path.join(__dirname, '/public/101.mp3'), {
        type: 'void'
      })
      reply = {
        type: 'voice',
        media_id: data.media_id
      }
    } else if (content === '012') {
      // 永久图片1 为图文消息
      // const {
      //   media_id
      // } = await client.handle('uploadMaterial', 'image', path.join(__dirname, 'public/2.jpg'), {
      //   type: 'image'
      // });
      // 永久图片2
      // const tutu = await client.handle('uploadMaterial', 'image', path.join(__dirname, 'public/xiaoxu1.jpg'), {
      //   type: 'image'
      // });
      // let media_id = 'mktoITGxDAsOhq5C12zkR5BOH30Et_MJP1o-PGp9n54'
      let media = {
        articles: [{
          title: '这是服务端上传的图文 1',
          thumb_media_id: 'mktoITGxDAsOhq5C12zkR0Hczdasba4NXSejQRkTERg',
          author: '江丽军',
          digest: '没有摘要',
          show_cover_pic: 1,
          content: '内容',
          content_source_url: 'https://www.qq.com/',
          need_open_comment: 1,
          only_fans_can_comment: 1
        }]
      }
      // 新增永久图文素材
      let uploadData = await client.handle('uploadMaterial', 'news', media, {
        type: news
      })
      // 上传图文消息内的图片获取URL
      // let data2 = await client.handle('uploadMaterial', 'pic', path.join(__dirname, '/public/xiaoxu.jpg'), {
      //   type: 'image'
      // })
      // console.log(data2);
    } else if (content === '013') {
      // 获取永久图文素材
      // let news = 'mktoITGxDAsOhq5C12zkRyEwjOyK7apg23mz4Y7TBes';
      // const data = await client.handle('fetchMaterial', news, 'news', true);
      // console.log(data);
      // 获取永久语音
      // let voice = 'mktoITGxDAsOhq5C12zkR_UJKRfFwyISwGRIXOy0r64';
      // const data = await client.handle('fetchMaterial', voice, 'voice', true);

      // 获取 永久视频
      // let video = 'mktoITGxDAsOhq5C12zkR9Dt3jqbLnWKExXHc5F1uuQ';
      // const data = await client.handle('fetchMaterial', video, 'video', true);
      // 获取 永久图片
      let image = 'mktoITGxDAsOhq5C12zkRyQ-94LvSVpYkeNWboU5EMA'
      const data = await client.handle('fetchMaterial', image, 'image', true)
      console.log(data)
      // 获取临时 图片
      // let imag = 'aOg696tkVPkuxye8ObYx31eFexR0ECx6CX2Ihf5fmwu-DxqfaFy4SXAYeJ1MbeKv';
      // const data = await client.handle('fetchMaterial', imag, 'image', false)
      // console.log(data);
    } else if (content === '014') {
      // 删除永久素材
      // 语音 图片
      // const voice = 'mktoITGxDAsOhq5C12zkR0Bbppg_El8ydVjPa0FQpcE';
      const video = 'mktoITGxDAsOhq5C12zkR-3tqH3b5_AFD-aEFJ7prkE'
      // const image = 'mktoITGxDAsOhq5C12zkRzmGEypstSUOKeE4ZpS15GY'
      const data = await client.handle('deleteMaterial', video)
      if (!data.errcode) {
        reply = '删除永久素材成功'
      } else {
        reply = '删除永久素材失败，' + '原因' + JSON.stringify(data)
      }
      console.log('***************')
      console.log(data)
    } else if (content === '015') {
      // 修改永久素材
      let media_id = 'mktoITGxDAsOhq5C12zkR67BiqlLJFJ9t-TqQ7uJ5B4'
      let image = 'mktoITGxDAsOhq5C12zkR5BOH30Et_MJP1o-PGp9n54'
      const newsList = {
        media_id: media_id,
        index: 1,
        articles: {
          title: '我的隔壁是女大娘们傻大逼',
          thumb_media_id: image,
          author: '江丽军1001',
          digest: '女大娘们傻大逼',
          show_cover_pic: 1,
          content: "<img src='http://mmbiz.qpic.cn/mmbiz_jpg/8qLKicXZczwuia46MuhHbKzAytkbWrcZxO1iaoiczOrIjcZKIsquExS2deiaAsaac49Y7mgribM4WYuywTlB9kS1jPMA/0'>",
          content_source_url: 'https://napyy.com/hosts/5e5fc7ffe4b3440008d4538c'
        }
      }
      const data = await client.handle('updateMaterial', media_id, newsList)
      if (!data.errcode) {
        reply = '修改永久图文素材成功'
      } else {
        reply = '修改永久图文素材失败'
      }
    } else if (content === '016') {
      // 获取素材总数
      const counts = await client.handle('countMaterial')
      reply = JSON.stringify(counts)
    } else if (content === '017') {
      // 获取素材列表
      const options1 = {
        type: 'image',
        offset: 0,
        count: 15
      }
      const options2 = {
        type: 'video',
        offset: 0,
        count: 12
      }
      const options3 = {
        type: 'voice',
        offset: 0,
        count: 12
      }
      const options4 = {
        type: 'news',
        offset: 0,
        count: 12
      }

      const data = await client.handle('batchMaterial', options4);
      // const data = await Promise.all([
      //   client.handle('batchMaterial', options1),
      //   client.handle('batchMaterial', options2),
      //   client.handle('batchMaterial', options3),
      //   client.handle('batchMaterial', options4)
      // ])
      console.log(data)
      // reply = `
      //   image: ${data[0].total_count}
      //   video: ${data[1].total_count}
      //   voice: ${data[2].total_count}
      //   news: ${data[3].total_count}
      // `
    } else if (content === '018') {
      // 回复图文
      let picUrl =
        'http://mmbiz.qpic.cn/mmbiz_jpg/8qLKicXZczwuia46MuhHbKzAytkbWrcZxO1iaoiczOrIjcZKIsquExS2deiaAsaac49Y7mgribM4WYuywTlB9kS1jPMA/0'
      // 图文id
      let media_id = 'mktoITGxDAsOhq5C12zkRyEwjOyK7apg23mz4Y7TBes'
      const news = []
      const {
        news_item
      } = await client.handle('fetchMaterial', media_id, 'news', true)
      news_item.forEach(element => {
        news.push({
          title: element.title,
          description: element.content,
          picUrl,
          url: 'https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&rsv_idx=1&tn=baidu&wd=%E6%97%B6%E9%97%B4%E6%88%B3&rsv_t=cbe3VjwsLa6d9H1hahrDgEntwyT%2FThVPRBC6QZH2%2Ftudu0VF6EmK4%2BNY%2FPE&rsv_enter=1&rsv_dl=tb&rsv_sug3=13&rsv_sug1=20&rsv_sug7=101&rsv_sug2=0&inputT=7469&rsv_sug4=7469&rsv_sug=1'
        })
      })
      reply = news
    } else if (content === '019') {
      // 创建创建标签
      // const data = await client.handle('createTag', 'w2');
      // 获取标签
      const data = await client.handle('fetchTags')
      // 编辑标签
      // const data = await client.handle('updateTag', 102, '天涯海角');
      // 删除标签
      // const data = await client.handle('delTag', 101)
      // 批量打标签/取消标签
      // const data = await client.handle('batchTag', [message.FromUserName], 100, false)
      // 获取标签下的粉丝列表
      // const data = await client.handle('fetchTagUsers', 102)
      // 获取用户身上的标签列表
      // const data = await client.handle('getUserTags', message.FromUserName)
      console.log('--------')
      console.log(data)
    } else if (content === '020') {
      // 获取帐号的关注者列表
      const {
        total
      } = await client.handle('fetchUserList')
      reply = total + '个人关注'
    } else if (content === '021') {
      // 对指定用户设置备注名
      const data = await client.handle('remarkUser', message.FromUserName, '我是江丽军')
      if (!data.errcode) {
        reply = '修改用户备注名成功'
      } else {
        reply = '修改用户备注名失败'
      }
    } else if (content === '022') {
      // 获取用户基本信息(UnionID机制)
      // 用户基本信息
      const data = await client.handle('getUserInfo', message.FromUserName)
      // 批量获取用户基本信息
      // const data = await client.handle('fetchBatchUsers', [{
      //   openid: message.FromUserName,
      //   lang: 'zh_CN'
      // }]);
      console.log(JSON.stringify(data))
    } else if (content === '023') {
      // 缩略图 为群发做准备

      let newList1 = {
        thumb_media_id: '1PXPpOAPqqKQd2Po2WrTy4Hdz7Mcf0oMjWkkR4yxYEr3oMJ4j13Gd1jvQUHhzk1h',
        author: '蒋江江',
        title: '测试群发',
        content_source_url: 'www.qq.com',
        content: '内容',
        digest: '描述描述',
        show_cover_pic: 1,
        need_open_comment: 1,
        only_fans_can_comment: 1
      }
      const data = await client.handle('massUploadNews', newList1, newList1)
      console.log(data)
    } else if (content === '024') {
      // 根据标签进行群发
      // 图文消息 news
      // const newsId = 'mktoITGxDAsOhq5C12zkR67BiqlLJFJ9t-TqQ7uJ5B4'
      // const data = await client.handle('sendByGroup', "news", newsId, 100);
      // 图片 image
      // const imageId = 'mktoITGxDAsOhq5C12zkRyQ-94LvSVpYkeNWboU5EMA';
      // const data = await client.handle('sendByGroup', "image", imageId, 100);
      // 文本 text
      const text = '<a href="www.baidu.com">百度</a>'
      const data = await client.handle('sendByGroup', 'text', text, 100)
      console.log('#$@####@@@#@##')
      console.log(data)
    } else if (content === '025') {
      // 根据标签进行群发 换取video media_id
      // const data = await client.handle('sendByMedia', {
      //   title: "傻逼",
      //   description: 'description',
      //   media_id: 'RONayoCCROIEuOIaHHmYX7_N2AsUHbbPlUDU6m3GpDrymsTAuuyqTEf-ifAfVeoq'
      // });
      const videoId = 'EDYfqyFbVXKcHx2Ons4gWjDED57YoXLS_9_LEELqtiFkTMfZ1EJmvWBij7K4MWWR'
      const data = await client.handle('sendByGroup', 'video', videoId, 100)
      console.log(data)
    } else if (content === '026') {
      // 根据OpenID列表群发 news video
      // const data = await client.handle('sendByOpenID', 'news', 'jfZ7i-NdeWgA0S39Z73qm2emLx71Fsb_tJCC-ympHhGhb1nchNdk2wuYpL8-3uv3', [message.FromUserName, '']);
      // const data = await client.handle('sendByOpenID', 'video', 'EDYfqyFbVXKcHx2Ons4gWjDED57YoXLS_9_LEELqtiFkTMfZ1EJmvWBij7K4MWWR', [message.FromUserName, '']);
      const data = await client.handle('sendByOpenID', 'text', '测试', [message.FromUserName, ''])
      console.log(data)
    } else if (content === '027') {
      // 删除群发 删除图文
      const data = await client.handle('deleteSend', {
        msg_id: 3147483658
      })
      console.log(data)
    } else if (content === '028') {
      // 预览接口
      // news
      // const data = await client.handle('sendPreview', 'news', 'Ifg0tq_DmYzW-lG6A5-y4iEHYcodaWL4z4e0KYb6WPN_nVZxkEJTsQmmKacdB_nJ', message.FromUserName);
      // video
      // const data = await client.handle('sendPreview', 'video', 'EDYfqyFbVXKcHx2Ons4gWjDED57YoXLS_9_LEELqtiFkTMfZ1EJmvWBij7K4MWWR', message.FromUserName);
      // image
      const data = await client.handle(
        'sendPreview',
        'image',
        'mktoITGxDAsOhq5C12zkR6a-gZxXKvIuyYvulfnlRDI',
        message.FromUserName
      )
      console.log(data)
    } else if (content === '029') {
      // 查询群发消息发送状态
      const {
        msg_id,
        msg_status
      } = await client.handle('sendGet', '1000000009')
      if (msg_status === 'SEND_SUCCESS') {
        reply = 'msg_id' + ': ' + msg_id + ' ' + '发送成功'
      } else if (msg_status === 'SENDING') {
        reply = 'msg_id' + ': ' + msg_id + ' ' + '发送中'
      } else if (msg_status === 'SEND_FAIL') {
        reply = 'msg_id' + ': ' + msg_id + ' ' + '发送失败'
      } else if (msg_status === 'DELETE') {
        reply = 'msg_id' + ': ' + msg_id + ' ' + '删除了'
      }
      // const data = await client.handle('');
      // console.log(data);
    } else if (content === '030') {
      // 创建二维码ticket 临时 整型
      const data = await client.handle('createQrcode', {
        time: 10800,
        scene: 1221
      })
      // 创建二维码ticket 临时 字符串
      // const data = await client.handle('createQrcode', {
      //   time: 7200,
      //   scene: 'bbut1001'
      // });
      // 创建二维码ticket 永久 整型
      // const data = await client.handle('createQrcode', {
      //   scene: 151
      // });
      // 创建二维码ticket 永久 字符串
      // const data = await client.handle('createQrcode', {
      //   scene: '1001'
      // });
      // 通过ticket换取二维码
      // const data = await client.showQrcode(
      //   'gQEc7zwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyaDN1cXhNd1RlVmsxaDcxRmh1MXMAAgQX12heAwQwKgAA'
      // )
      console.log(data)
    } else if (content === '031') {
      // 长连接转短连接
      // const url = 'https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&rsv_idx=1&tn=baidu&wd=npm&oq=QrReader&rsv_pq=ffaf455f000a2928&rsv_t=2f35rerrMZzGb2%2B%2Bt3HFXZN1yeM%2FZ2uc5tFSqnuYjcHJgYz%2BoCsJbc2z8f4&rqlang=cn&rsv_enter=0&rsv_dl=tb&inputT=2697&rsv_sug3=6&rsv_sug1=4&rsv_sug7=101&rsv_sug2=0&rsv_sug4=2697'；
      // const data = await client.handle('createShortUrl', url);
      // 提交语音
      // const data = await client.handle('addvoice', path.join(__dirname, 'public/101.mp3'), {
      //   voice_id: 13201
      // })
      // 语音识别结果
      // const data = await client.handle("queryrecoresult", 13201);
      // 微信翻译
      const data = await client.handle('aiTranslate', '微信公众号', 'zh_CN', 'en_US')
      console.log(data)
    } else if (content === '032') {
      // 菜单
      // 查询菜单
      const data = await client.handle("queryMenu");
      console.log(JSON.parse(JSON.stringify(data.selfmenu_info.button[0])));
      // try {
      //   // 删除菜单
      //   await client.handle('deleteMenu')
      //   // 创建普通菜单
      //   const menu = require('./menu')
      //   const data = await client.handle('createMenu', menu)
      //   console.log(data)
      //   if (!data.errcode) {
      //     reply = '创建普通菜单成功'
      //   } else {
      //     reply = '创建菜单失败,错误码为：' + data.errcode
      //   }
      // } catch (error) {
      //   console.log('错误')
      //   console.log(error)
      // }
    } else if (content === '033') {
      // 创建个性菜单
      // const menu = require('./menu')
      // const rule = {
      //   "tag_id": 100,
      //   "sex": 1,
      //   "country": "中国",
      //   "province": "北京",
      //   "client_platform_type": "2",
      //   "language": "zh_CN"
      // }
      // const data = await client.handle('createMenu', menu, rule);
      // if (data.menuid) {
      //   reply = '个性菜单创建成功'
      // } else {
      //   reply = JSON.stringify(data);
      // }
      // 删除个性菜单
      // const data = await client.handle('deleteCustomMenu', 510290794);
      // if (!data.errcode) {
      //   reply = '删除个性菜单成功';
      // } else {
      //   reply = JSON.stringify(data);
      // }
      const data = await client.handle('trymatchMenu', 'iran_gui');
      console.log(JSON.parse(JSON.stringify(data.menu.button)));
    } else if (content === '034') {
      // const data = await client.handle('');
      // console.log(data);
    } else if (content === '035') {
      // const data = await client.handle('');
      // console.log(data);
    } else if (content === '036') {
      // const data = await client.handle('');
      // console.log(data);
    } else if (content === '037') {
      // const data = await client.handle('');
      // console.log(data);
    } else if (content === '038') {
      // const data = await client.handle('');
      // console.log(data);
    } else if (content === '039') {
      // const data = await client.handle('');
      // console.log(data);
    }
    ctx.body = reply
  } else if (message.MsgType === 'event') {
    // 用户未关注时，进行关注后的事件推送
    if (message.Event === 'subscribe') {
      console.log('关注')
      console.log(message.Ticket)
      if (message.EventKey) {
        console.log('扫二维码进来的')
        console.log(message.EventKey)
        console.log(message.Ticket)
      }
      ctx.body = '关注江丽军公众'
    } else if (message.Event === 'SCAN') {
      // 用户已关注时的事件推送 SCAN
      console.log('scan')
      console.log(message.EventKey)
      console.log(message.Ticket)
    } else if (message.Event === 'unsubscribe') {
      // 取消关注 取消订阅
      console.log('取消关注')
    } else if (message.Event === 'LOCATION') {
      // 地理位置
      console.log('地理位置')
      console.log(message.Latitude)
      console.log(message.Longitude)
    } else if (message.Event === 'CLICK') {
      // 点击自定义菜单
      console.log('点击自定义菜单')
      console.log(message.EventKey)
    } else if (message.Event === 'VIEW') {
      // 点击菜单跳转链接时的事件推送
      console.log('菜单跳转')
      console.log('事件KEY值，设置的跳转URL')
      console.log(message.EventKey)
      console.log('指菜单ID，如果是个性化菜单，则可以通过这个字段，知道是哪个规则的菜单被点击了')
      console.log(message.MenuID)
    } else if (message.Event === 'scancode_push') {
      // scancode_push：扫码推事件的事件推送
      console.log('scancode_push：扫码推事件的事件推送')
      console.log('事件KEY值')
      console.log(message.EventKey)
      console.log('扫描信息')
      console.log(JSON.stringify(message.ScanCodeInfo))
      console.log('扫描结果')
      console.log(message)
    } else if (message.Event === 'scancode_waitmsg') {
      // scancode_waitmsg：扫码推事件且弹出“消息接收中”提示框的事件推送
      console.log('scancode_waitmsg：扫码推事件且弹出“消息接收中”提示框的事件推送')
      console.log('事件KEY值')
      console.log(message.EventKey)
      console.log('扫描信息')
      console.log(JSON.stringify(message.ScanCodeInfo))
      console.log('扫描结果')
      console.log(message)
    } else if (message.Event === 'pic_sysphoto') {
      // pic_sysphoto：弹出系统拍照发图的事件推送
      console.log('pic_sysphoto：弹出系统拍照发图的事件推送')
      console.log('事件KEY值')
      console.log(message.EventKey)
      console.log('发送的图片信息')
      console.log(JSON.parse(JSON.stringify(message.SendPicsInfo.PicList)));
      console.log('发送的图片数量')
      console.log(message.SendPicsInfo.Count)
      console.log('图片的MD5值，开发者若需要，可用于验证接收到图片')
    } else if (message.Event === 'pic_photo_or_album') {
      // pic_photo_or_album：弹出拍照或者相册发图的事件推送
      console.log('pic_photo_or_album：弹出拍照或者相册发图的事件推送')
      console.log('事件KEY值')
      console.log(message.EventKey)
      console.log('发送的图片信息')
      console.log(JSON.parse(JSON.stringify(message.SendPicsInfo.PicList)))
      console.log('发送的图片数量')
      console.log(message.SendPicsInfo.Count)
      console.log('图片的MD5值，开发者若需要，可用于验证接收到图片')
    } else if (message.Event === 'pic_weixin') {
      // pic_weixin：弹出微信相册发图器的事件推送
      console.log('pic_weixin：弹出微信相册发图器的事件推送')
      console.log('事件KEY值')
      console.log(message.EventKey)
      console.log('发送的图片信息')
      console.log(JSON.parse(JSON.stringify(message.SendPicsInfo.PicList)))
      console.log('发送的图片数量')
      console.log(message.SendPicsInfo.Count)
      console.log('图片的MD5值，开发者若需要，可用于验证接收到图片')
    } else if (message.Event === 'location_select') {
      // location_select：弹出地理位置选择器的事件推送
      console.log('location_select：弹出地理位置选择器的事件推送')
      console.log('事件KEY值')
      console.log(message.EventKey)
      console.log('发送的位置信息')
      console.log(JSON.stringify(message.SendLocationInfo))
      console.log('X坐标信息')
      console.log(message.Location_X)
      console.log('Y坐标信息')
      console.log(message.Location_Y)
      console.log('地理位置的字符串信息')
      console.log(message.Label)
    } else if (message.Event === 'view_miniprogram') {
      // view_miniprogram：点击菜单跳转小程序的事件推送
      console.log('view_miniprogram：点击菜单跳转小程序的事件推送')
      console.log('事件KEY值跳转的小程序路径')
      console.log(message.EventKey)
      console.log('菜单ID，如果是个性化菜单，则可以通过这个字段，知道是哪个规则的菜单被点击了')
      console.log(message.MenuID)
    } else if (message.Event === 'MASSSENDJOBFINISH') {
      // 事件推送群发结果 群发
      console.log('件推送群发结果')
      console.log('----群发的结果----')
      console.log(message.Status) // 群发的结果
      console.log('-----成功的粉丝数-----')
      console.log(message.SentCount) // 发送成功的粉丝数
      console.log(message.ErrorCount) // 失败粉丝数
      console.log(message.TotalCount) // 粉丝数
    } else if (message.Event === 'qualification_verify_success') {
      // 资质认证成功
      console.log('资质认证成功')
      console.log('有效期' + ' ' + message.ExpiredTime)
    } else if (message.Event === 'qualification_verify_fail') {
      // 资质认证失败
      console.log('资质认证失败')
      console.log('资质认证失败原因')
      console.log(JSON.stringify(message.FailReason))
    } else if (message.Event === 'naming_verify_success') {
      // 名称认证成功
      console.log('名称认证成功')
      console.log('有效期: ' + message.ExpiredTime)
    } else if (message.Event === 'naming_verify_fail') {
      // 名称认证失败
      console.log('名称认证失败')
      console.log('名称认证失败原因')
      console.log(JSON.stringify(message.FailReason))
    } else if (message.Event === 'annual_renew') {
      // 年审通知
      console.log('提醒公众号需要去年审了')
    }
  }
  await next()
}
